const path = require('path')

const publicPath = {
    development: '/',
    test: '/light-app-test',
    production: '/light-app'
}

function resolve(dir) {
    return path.join(__dirname, dir)
}

const config = {
    lintOnSave: false,
    publicPath: "./",
    // publicPath: publicPath[process.env.NODE_ENV],
    devServer: {
        port: 9000
    },
    pages: {
        index: {
            entry: 'src/main.js',
            template: 'public/index.html',
            filename: 'index.html',
            title: '信息中心项目管理系统后台',
            chunks: ['chunk-vendors', 'chunk-common', 'index']
        }
    },
    chainWebpack: config => {
        config.resolve.alias
            .set('@$', resolve('src'))
            .set('@apis', resolve('src/apis'))
            .set('@assets', resolve('src/assets'))
            .set('@components', resolve('src/components'))
            .set('@config', resolve('src/config'))
            .set('@light-app', resolve('src/light-app'))
            .set('@mixins', resolve('src/mixins'))
            .set('@router', resolve('src/router'))
            .set('@static', resolve('src/static'))
            .set('@store', resolve('src/store'))
            .set('@utils', resolve('src/utils'))
            .set('@vendor', resolve('src/vendor'))
            .set('@views', resolve('src/views'))
        config.output.filename('js/[name].[hash].js').end()
    },
    css: {
        extract: {
            filename: 'css/[name].[hash:8].css',
            chunkFilename: 'css/[name].[hash:8].css'
        }
    }
}

module.exports = config